/*
 * Copyright © 2024-2025 Wenze Wei
 *
 * This file is part of StadionOS.
 *
 * This Source Code Form is subject to the terms of the GNU General Public License, v. 2.0.
 * You can obtain a copy of the GPL at
 * https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 */

#include "test.h"

void test_time() {
    time_t current_time;
    Stime(&current_time);

    Sprint("Current time: %s\n", Sctime(&current_time));

    struct Ttm *tm_info = Slocaltime(&current_time);
    char buffer[32];
    Sstrftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", tm_info);
    Sprint("Formatting time: %s\n", buffer);
    
    time_t now = Stime(NULL);
    struct Ttm *local_time = Slocaltime(&now);  
    
    Sprint("Local time: %04d-%02d-%02d %02d:%02d:%02d\n",   
           local_time->tm_year + 1900, local_time->tm_mon + 1, local_time->tm_mday,  
           local_time->tm_hour, local_time->tm_min, local_time->tm_sec);  
    
    Sfree(local_time);
}
